package com.yx.common.config;

import org.slf4j.MDC;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LogConfig {

    @Bean
    public void setupMDC() {
        // 为每个请求生成唯一的追踪 ID
        String traceId = generateUniqueTraceId();
        MDC.put("traceId", traceId);  // 设置 MDC 的 traceId
    }

    private String generateUniqueTraceId() {
        return java.util.UUID.randomUUID().toString();
    }
}
